package com.justgame.project.service.system.service.basic;

import com.justgame.project.service.system.entity.SysDict;
import com.justgame.project.service.system.query.SysDictQuery;
import com.justgame.project.service.system.wrapper.SysDictWrapper;
import com.justgame.project.base.servcice.IBasicService;
import java.lang.Long;
import org.springframework.util.Assert;
import org.springframework.lang.NonNull;
import java.lang.String;

/**
 *
 * 系统字典服务自定义查询类
 *
 * @@tableName sys_dict
 * @author Zwb
 */
@SuppressWarnings("all")
public interface BasicSysDictService extends IBasicService<SysDictQuery,SysDict,SysDictWrapper> {

   /**
    * 新增创建
    * @param parentId 父级id
    * @param code 字典编号
    * @param key 键
    * @param value 值
    * @param remark 备注
    */
   default SysDict baseAdd(Long parentId, String code, String key, String value, String remark){
      SysDict sysDict = new SysDict();
      sysDict.setParentId(safeValue(parentId, null));
      sysDict.setCode(safeValue(code, null));
      sysDict.setKey(safeValue(key, null));
      sysDict.setValue(safeValue(value, null));
      sysDict.setRemark(safeValue(remark, null));
      save(sysDict);
      return sysDict;
   }

   /**
    * 更新
    * @param parentId 父级id
    * @param code 字典编号
    * @param key 键
    * @param value 值
    * @param remark 备注
    */
   default boolean baseUpdate(@NonNull SysDict sysDict,Long parentId, String code, String key, String value, String remark){
      Assert.notNull(parentId,"必须提供父级id");
      Assert.notNull(key,"必须提供键");
      Assert.notNull(value,"必须提供值");
      Assert.notNull(code,"必须提供字典编号");
      Assert.notNull(remark,"必须提供备注");
      Assert.notNull(sysDict.getId(),"必须提供主键ID");
      sysDict.setParentId(safeValue(parentId, null));
      sysDict.setCode(safeValue(code, null));
      sysDict.setKey(safeValue(key, null));
      sysDict.setValue(safeValue(value, null));
      sysDict.setRemark(safeValue(remark, null));
      return updateById(sysDict);
   }

}